import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToMany, JoinTable } from 'typeorm';
import { User } from './User'

// 实体类 映射为数据库里的一张表
@Entity()
export class Role {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ length: 50 })
    role: string;

    @CreateDateColumn()
    createdAt: Date;

    @UpdateDateColumn()
    updatedAt: Date;

    // 多对多02
    @ManyToMany(() => User, (user) => user.roles)
    // @JoinTable()        //所有者所创建出的表名 role_users_user
    users: User[]
}
